var prgm = null;
var timeout = 0;

function NanoManageListFile()
{
	GetPageContent('GET', 'nano/nanofile.php?do=list', '', NanoCheckListFile, null, true);
}

function NanoCheckListFile(success, text, param)
{
	if(success == false) { NanoSetNotif('Impossible de se connecter au serveur'); return; }
	var e = document.getElementById('nc_fight_file');
	e.innerHTML = text;
}

function NanoCheckFile(e)
{
	var code = e.getElementsByTagName('div')[0];
	prgm = e.getElementsByTagName('span')[0].innerHTML;
	var editor = document.getElementById('nc_fight_prgm');
	editor.value = code.innerHTML;
}

function NanoSetFightProgram(id)
{
	if(prgm == null) { NanoSetNotif('Aucun program sélectionné'); return; }
	GetPageContent('GET', 'nano/nanomanage.php?id=' + id + '&file=' + prgm, '', NanoCheckSetFightProgram, null, true);
}

function NanoCheckSetFightProgram(success, text, param)
{
	if(success == false) { NanoSetNotif('Impossible de se connecter au serveur'); return; }
	var data = text.split('//');
	if(data[0] == '1') setTimeout('document.location = "nanofight.php";', 3000);
	NanoSetNotif(data[1]);
}

function NanoSetNotif(text)
{
	var result = document.getElementById('nc_notif');
	result.innerHTML = text;
	result.style.visibility = '';
	if(timeout != null) clearTimeout(timeout);
	timeout = setTimeout('NanoHideNotif();', 5000);
}

function NanoHideNotif()
{
	var result = document.getElementById('nc_notif');
	result.style.visibility = 'hidden';
}